<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的消费二维码</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <style>
        body {
            font-size: 14px;
        }
    </style>
</head>
<body>
<div class="contains">

    <div class="kongshuju">
        <p>暂无数据</p>
    </div>
    <div class="contain orderLists">
        <ul class="aui-list-view after-no-border" id="orderList-content">
        </ul>
    </div>


</div>

<script id="orderList-template" type="text/x-dot-template">

        {{ for (var i in it) { }}
        <li class="aui-list-view-cell" tapmode data-qrid="{{=it[i].supcheck_code}}" data-name="{{=it[i].goods[0].goods_name}}" onclick="openQRInfo(this)">
            <div class="aui-arrow-right" style="height:30px;line-height: 30px;">
                {{=it[i].goods[0].goods_name}}{{=it[i].goods[0].goods_number}}张
                <!-- <span class="aui-pull-right aui-margin-r-15 color-gray">详情</span> -->
            </div>
        </li>
        {{}}}

</script>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/myInfo.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.js"></script>
<script type="text/javascript" src="../script/iscroll2.js"></script>
<script type="text/javascript">
    var page = 1, isLock = false, orderType = 2, status = 1, myOrderId, orderType = "";
    var vmoney = "";
    apiready = function () {
        api.parseTapmode();
//        api.setRefreshHeaderInfo({
//            visible : true,
//            loadingImg : 'widget://image/ptr_pull.png',
//            bgColor : '#efeff4',
//            textColor : '#959595',
//            textDown : '下拉刷新',
//            textUp : '松开刷新',
//            showTime : true
//        }, function(ret, err) {
//            page = 1;
//            getData(catid);
//            api.refreshHeaderLoadDone();
//        });
        getQROrder();
        api.addEventListener({
            name: 'scrolltobottom'
        }, function (ret, err) {
            page++;
            if (!isLock) getQROrder();
        });

    }
    function openQRInfo(obj) {
        var companyName=$(obj).attr("data-name");
        var qrId=$(obj).attr("data-qrid");
        api.openWin({
            name: "consumeQRcodeInfo_win",
            url: "consumeQRcodeInfo_win.html",
            pageParam: {
                qrId: qrId,
                companyName: companyName
            }
        })
    }
    function changeContent(type) {
        isLock=false;
        if (type == "consume") {
            //已消费
            status=2;
        } else {
            status=1;
        }
        $("#orderList-content").empty();
        page=1;
        getQROrder();
    }
    function getQROrder() {
        if (isLock)return;

//        toPage = toPage ? toPage : page;
//        if (toPage == 1) api.refreshHeaderLoading();
        data = {
            page: page,
            status: status,
            order_type: 2,
            count:10

        };
        url = "order/list";
        isLock = true;
        ajaxRequest(url, 'get', data, function (ret, err) {
            api.refreshHeaderLoadDone();
            isLock = false;
            var content = $api.byId('orderList-content');
            var tpl = $api.byId('orderList-template').text;
            var tempFn = doT.template(tpl);
//            alert(ret.data[0]["order_id"])
            if (page > 1) {
                if (!$.trim(ret.data)) {
                    isLock = true;
                    return;
                }
                $api.append(content, tempFn(ret.data));
            } else {
                showNoTip(ret.data)
                $api.html(content, tempFn(ret.data));
            }

        });
    }
</script>
</html>